window.onload = function(){
    addnum();
    let cookieStr= document.cookie;
    let cookirArr=cookieStr.split(";");
    let bool=false;
    let username;;
    for(let i=0;i<cookirArr.length;i++){
         //去除空格
      let str=cookirArr[i].trim();
 
       let key="username=";
       if(str.startsWith(key)){
         bool=true;
         username=str.substring(key.length,str.length);
         break;
       }
    }
 
    //判断bool标记值
    if(bool){
     console.log(username);
    }else{
         location.href='登录注册.html'
    }

}

function addnum(){

    let numobj  = document.getElementsByClassName("num");
    let num138 = numobj[0].innerHTML
    let num95 = numobj[1].innerHTML
    let num1 = numobj[2].innerHTML
    let num567 = numobj[3].innerHTML

    let numadd0 = setTimeout(addnum,500)
    let numadd1 = setTimeout(addnum,500)
    let numadd2 = setTimeout(addnum,500)
    let numadd3 = setTimeout(addnum,500)

    if(num138 == 138){
        clearTimeout(numadd0)
    }else{
        numobj[0].innerHTML =++ num138;
    }

    if(num95 == 95){
        clearTimeout(numadd1)
    }else{
        numobj[1].innerHTML =++ num95;
    }

    if(num1 == 1){
        clearTimeout(numadd2)
    }else{
        numobj[2].innerHTML =++ num1;
    }
     
    if(num567 == 567){
        clearTimeout(numadd3)
    }else{
        numobj[3].innerHTML =++ num567;
    }
}